import { _decorator, Component, Node } from 'cc';
const { ccclass, property } = _decorator;

@ccclass('Bg')
export class Bg extends Component {

    @property(Node)
    bg01:Node=null;
    @property(Node)
    bg02:Node=null;

    @property
    speed:number=100;

    start() {

    }

    update(deltaTime: number) {
        let bgposition01=this.bg01.position;
        this.bg01.setPosition(bgposition01.x,bgposition01.y-this.speed*deltaTime,bgposition01.z)
        let bgposition02=this.bg02.position;
        this.bg02.setPosition(bgposition02.x,bgposition02.y-this.speed*deltaTime,bgposition02.z)
        
        let p1=this.bg01.position;
        let p2=this.bg02.position;

        if(this.bg01.position.y<-852){
            this.bg01.setPosition(this.bg02.position.x,this.bg02.position.y+852,this.bg02.position.z)
        }
        if(this.bg02.position.y<-852){
            this.bg02.setPosition(this.bg01.position.x,this.bg01.position.y+852,this.bg01.position.z)
        }
    }
}


